<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;
use think\Session;
class Basiczd extends Basic
{
	
    
 public function site()
    {
	   $post=input("post.");//获取post数据'
	 
		  if($post){
		    $up=upload('photo_img');
		   if(!empty($up['error'])){
		   $this->error($up['error']);
		   
		   }
		   if($up!='') $post['photo_img']=$up;
		   else unset($post['photo_img']);
            
             $up=upload('indexlb3');
		   if(!empty($up['error'])){
		   $this->error($up['error']);
		   
		   }
		   if($up!='') $post['indexlb3']=$up;
		   else unset($post['indexlb3']);
            
             $up=upload('indexlb2');
		   if(!empty($up['error'])){
		   $this->error($up['error']);
		   
		   }
		   if($up!='') $post['indexlb2']=$up;
		   else unset($post['indexlb2']);
            
             $up=upload('indexlb1');
		   if(!empty($up['error'])){
		   $this->error($up['error']);
		   
		   }
		   if($up!='') $post['indexlb1']=$up;
		   else unset($post['indexlb1']);

		   $upf=upload('wxwm');
		   if(!empty($upf['error'])){
		   $this->error($upf['error']);
		   
		   }
		   if($upf!='') $post['wxwm']=$upf;
		   else unset($post['wxwm']);
		  
		   unset($post['editorValue']);
		  unset($post['data']);
		    
           $config= Db::name('config')->find();
		  
           Db::name('config')->where("id",$config['id'])->update($post);
		   $this->success('操作成功！');
		  
		  }else{
              $config= Db::name('config')->find();
              $this->assign('config',$config); 
              return $this->fetch();
			  
			  }
    }

	public function publicd()
    {
     $post=input("post.");//获取post数据'
	 
		  if($post){
		   
		  unset($post['editorValue']);
		  unset($post['data']);
		   
           $config= Db::name('zcconfig')->find();
		  
           Db::name('zcconfig')->where("id",$config['id'])->update($post);
		   $this->success('操作成功！');
		  
		  }else{
              $config= Db::name('zcconfig')->find();
              $this->assign('config',$config); 
              return $this->fetch();
			  
			  }
     return $this->fetch();
    }


     public function payment()
    {
     $user= Db::name('pay')->paginate(10);
	 $this->assign('user',$user); 
     return $this->fetch();
    }

	 public function payxg()
    {//修改
		 $post=input("post.");
			       
		if($post){
          $up=upload('pic');
		   if(!empty($up['error'])){
		   $this->error($up['error']);
		   
		   }
		   if($up!='') $post['pic']=$up;
		   else unset($post['pic']);



		  $id=$post['id'];unset($post['id']);
		   $fin=Db::name('pay')->where('id',$id)->find();
           if(!$fin){ $this->success('该充值方式不存在');}
		   Db::name('pay')->where('id',$id)->update($post);
		   $this->success('操作成功！');
		}else{
     $id=input('param.id');
    $user= Db::name('pay')->where('id',$id)->find();
	
	 $this->assign('userf',$user); 
     return $this->fetch();
	   }
    }
    public function payadd()
    {//添加
		 $post=input("post.");
			       
		if($post){
          $up=upload('pic');
		   if(!empty($up['error'])){
		   $this->error($up['error']);
		   
		   }
		   if($up!='') $post['pic']=$up;
		   else unset($post['pic']);
		   $fin=Db::name('pay')->where(array('zwname'=>$post['zwname']))->find();
		   //dump($fin);die;
           if($fin){ $this->success('该充值方式已存在');}
		   $post['addtime']=date("Y-m-d H:i:s");
		   $insert=Db::name('pay')->insert($post);
		   $this->success('操作成功！');
		}else{
     $id=input('param.id');
  
	
	 $this->assign('id',$id); 
     return $this->fetch();
	   }
    }
  
		public function paydel()
    {//删除
		 $post=input("param.");
			       
		if($post){
		  $id=$post['id'];unset($post['id']);
		  $fin=Db::name('pay')->where('id',$id)->find();
           if(!$fin){ $this->success('该充值方式已存在');}
		   Db::name('pay')->where('id',$id)->delete();
		   $this->success('操作成功！');
		}
    }
  
  
    public function admin(){
	  
	    $post=input("post.");//获取post数据'
	 
		  if($post){
		   
		 
		  
		  }else{
              $admin= Db::name('admin')->paginate(10);
              $this->assign('admin',$admin); 
              return $this->fetch();
			  
			  }
     
	  }
	  public function upadmin(){
	  
	    $post=input("post.");
			       
		if($post){
			
	      
          
		   $id=$post['id'];
           $user= Db::name('admin')->where('id',$post['id'])->find();
		   if($post['password']==$user['password']){unset($post['password']);}
           else $post['password']=md5($post['password']);
           unset($post['id']);
           Db::name('admin')->where('id',$id)->update($post);
		   $this->success('操作成功！');
		
		}else{
		$id=input('param.id');
    $admin= Db::name('admin')->where('id',$id)->find();
	
	 $this->assign('admin',$admin); 
     return $this->fetch();
	   }
     
	  }


}
